#!/usr/bin/env python
#!coding=utf-8

from bs4 import BeautifulSoup as bs

'''
解析单个文件
支持解析规则
根据解析规则，得到解析的结果
这个结果放在JSON文件中

'''

def parse(file_path):
    fb = open(file_path)
    html_doc = fb.read()
    soup = bs (html_doc,'html.parser')
    img_list = soup.find_all('img')
   
    img_src_list = [] 

    for img  in img_list:
        img_src_list.append(img['src'])



    fb = open('img_src.txt','a+');
    buff = '';

    for img_src in img_src_list:
        buff = buff + img_src+ "\r\n"        


    print buff
    fb.write(buff)

    fb.close();
